package com.platform.server.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.platform.server.dao.MessageDao;
import com.platform.server.service.MessageService;

@Service
public class MessageServiceImpl implements MessageService {
	
	@Autowired
	private MessageDao messageDao;
	
	/**
	 * 查看消息列表
	 */
	@Override
	public List<Map<String, Object>> selectMessageList(Map<String,Object> map) {
		return messageDao.selectMessageList(map);
	}

	/**
	 * 修改消息状态
	 */
	@Override
	public int updateMessageStatus(Integer messageid) {
		return messageDao.updateMessageStatus(messageid);
	}
	
	/**
	 * 添加为系统消息
	 */
	@Override
	public int insertSystemMessage(String recevicer_id, String title, String content) {
		return messageDao.insertSystemMessage(recevicer_id, title, content);
	}

	/**
	 * 删除消息
	 */
	@Override
	public int deleteMessage(String id) {
		return messageDao.deleteMessage(id);
	}

	/**
	 * 添加消息
	 */
	@Override
	public int insertMessage(String title, String scope, String username, String content, String push_time) {
		Map<String,Object> map = new HashMap<>();
		map.put("title", title);
		map.put("scope", scope);
		map.put("username", username);
		map.put("content", content);
		map.put("push_time", push_time);
		return messageDao.insertMessage(map);
	}

	/**
	 * 编辑消息
	 */
	@Override
	public int updateMessage(String id, String title, String scope, String username, String content, String push_time) {
		Map<String,Object> map = new HashMap<>();
		map.put("id", Integer.parseInt(id));
		map.put("title", title);
		map.put("scope", scope);
		map.put("username", username);
		map.put("content", content);
		map.put("push_time", push_time);
		return messageDao.updateMessage(map);
	}

}
